<?php
namespace app\admin\controller;
use app\common\controller\Common;
use app\admin\model\ImportModel;
use app\common\controller\Files;
use think\Request;

/**
* 导入操作
*/
class Import extends Common
{
	private $temp = [
				'a'=>'gongyinshang.xls',
				'b'=>'goods.xls',
				];
	/**
	* 导入
	*/
	public function importgongyinshang()
	{
		if($_FILES)
		{
			$field = ['supplier_name','name','phone','address','years'];
			return json(ImportModel::import('supplier',$field));
		}
		return $this->fetch();
	}
	/**
	* 下载模板
	*/
	public function download()
	{
		$info = Request::instance()->param();
		$path = ROOT_PATH . 'public' . DS . 'upload' . DS . 'excel' . DS . 'temp' . DS . $this->temp[$info['do']];
		return Files::download($path,$this->temp[$info['do']]);
	}
	
}
